package com.study.javaOther.fingerguessing.game;

import com.study.javaOther.fingerguessing.participation.CommonPlayer;
import com.study.javaOther.fingerguessing.participation.ComputerPlayer;
import com.study.javaOther.fingerguessing.participation.Judgement;
import com.study.javaOther.fingerguessing.participation.Player;

public class Application {
    public static void main(String[] args) {
        startNewGame();
    }

    public static void startNewGame() {
        Player player1 = new CommonPlayer("玩家1");
        Player player2 = new ComputerPlayer();
        Judgement judgement = new Judgement(player1, player2);
        judgement.setTotalNum(5);
        System.out.println(judgement.showRole());

        while (!judgement.showWinner()) {
            judgement.judgeGame();
            System.out.println(player1.getName() + "赢了:" + player1.getScore());
            System.out.println(player2.getName() + "赢了:" + player2.getScore());

        }
        Player winner = judgement.getWinner();
        if (winner != null) {
            System.out.println("玩家:" + winner.getName() + " 率先赢:" + winner.getWin() + "场 胜利");
        } else {
            System.out.println("玩家:" + player1.getName() + "和玩家:" + player2.getName() + "平局 ");
        }
    }
}
